﻿Imports System.Data.OleDb

Public Class Profile
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    End Sub

    Protected Sub Btn_RequestFriendShip_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Btn_RequestFriendShip.Click
        If Request.QueryString("UserName") = "" Then Return

        If Request.QueryString("UserName") = User.Identity.Name Then
            LBL_Friendship.Text = "Can not Make Friendship to yourself"
            LBL_Friendship.ForeColor = Drawing.Color.Red
            Return
        End If


        Dim sql As String = "INSERT INTO Friend_Request (FromUserName, ToUserName, RequestApproved) VALUES (@f1,@f2,""0"")"
        Dim conn As OleDbConnection = New OleDbConnection(ConfigurationManager.ConnectionStrings("ConnectionString").ConnectionString)
        Dim cmd As OleDbCommand = New OleDbCommand(sql, conn)
        cmd.Parameters.AddWithValue("@f1", User.Identity.Name)
        cmd.Parameters.AddWithValue("@f2", Request.QueryString("UserName"))
        conn.Open()
        cmd.ExecuteNonQuery()
        conn.Close()
        cmd.Dispose()
        conn.Dispose()

        Response.Redirect("FriendshipRequest.aspx")

    End Sub
End Class